﻿Imports System.Data.OleDb
Imports System.Data
Imports System.Configuration
Imports System.Drawing
Imports System.Web.UI
Imports System.Web.UI.WebControls
Public Class Search
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim con As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("fishconn").ConnectionString)
        con.Open()

        Dim SqlString As String = " SELECT tblProfile.UserID,tblProfile.FirstName, tblProfile.LastName, aspnet_Users.UserName, aspnet_Users.LastActivityDate" & _
                                  " FROM aspnet_Users INNER JOIN tblProfile ON aspnet_Users.UserName = tblProfile.UserName " & _
                                  " WHERE (((tblProfile.FirstName) Like [@fname])) OR (((tblProfile.LastName) Like [@lname])) OR (((aspnet_Users.UserName) Like [@user]))" & _
                                  " ORDER BY aspnet_Users.LastActivityDate DESC "
        Dim cmd As OleDbCommand = New OleDbCommand(SqlString, con)
        cmd.CommandType = CommandType.Text
        cmd.Parameters.AddWithValue("@fname", txtfindprofile.Text)
        cmd.Parameters.AddWithValue("@lname", txtfindprofile.Text)
        cmd.Parameters.AddWithValue("@user", txtfindprofile.Text)
        Dim ds As DataSet = New DataSet
        Dim da As New OleDb.OleDbDataAdapter
        da.SelectCommand = cmd
        da.Fill(ds)
        GridView1.DataSource = ds
        GridView1.DataBind()
    End Sub

    Protected Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        Dim con As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("fishconn").ConnectionString)
        con.Open()

        Dim SqlString As String = "SELECT * FROM [tblDiscussion] WHERE ([DiscussionSubject] LIKE '%' + @topic + '%') ORDER BY [CreatedDate] DESC, [CreatedTime] DESC"
        Dim cmd As OleDbCommand = New OleDbCommand(SqlString, con)
        cmd.CommandType = CommandType.Text
        cmd.Parameters.AddWithValue("@topic", txtfinddiscus.Text)
        Dim ds As DataSet = New DataSet
        Dim da As New OleDb.OleDbDataAdapter
        da.SelectCommand = cmd
        da.Fill(ds)
        GridView2.DataSource = ds
        GridView2.DataBind()

    End Sub
End Class